import { fetcher } from '@/src/utils/fetcher'
import { getTranslations } from 'next-intl/server'
import { cookies } from 'next/headers'
import Hero from '../../components/hero'
import ScrollToTop from '../../components/scroll-to-top'

interface LayoutProps {
  children: React.ReactNode
}

const Layout: React.FC<LayoutProps> = async (props) => {
  const { children } = props
  const cookieStore = cookies()
  const [t, sliders] = await Promise.all([
    getTranslations('searchResult'),
    fetcher<Slider[]>('/api/index/adList?type=sousuo', {
      cookieStore,
    }),
  ])
  return (
    <main>
      <ScrollToTop />
      <Hero sliders={sliders} />
      {/* 移动端 */}
      <div className='px-[0.9375rem] lg:px-0 lg:max-w-[960px] lg:mx-auto 2xl:max-w-[1200px]'>
        <div
          id='searchResult'
          className='h-[1.875rem] lg:h-[2.1875rem] 2xl:h-[3.28125rem]'
        />
        {children}
      </div>
    </main>
  )
}

export default Layout
